﻿using System.Collections;
using System.Collections.Generic;
namespace TheSnakeGame.Engine
{
    public class Point : System.ComponentModel.INotifyPropertyChanged
    {
        private int x;
        private int y;

        public int X 
        {
            get { return this.x; }
            set
            {
                if (value != this.x)
                {
                    this.x = value;
                    this.OnPropertyChanged("X");
                }
            }
        }

        public int Y 
        {
            get { return this.y; }
            set
            {
                if (value != this.y)
                {
                    this.y = value;
                    this.OnPropertyChanged("Y");
                }
            }
        }

        public Point(int x, int y)
        {
            this.X = x;
            this.Y = y;
        }

        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
            }
        }
    }

    internal class  PointComperer : IEqualityComparer<Point>
    {
        public bool Equals(Point firstPoint, Point secondPoint)
        {
            if (firstPoint.X == secondPoint.X && firstPoint.Y == secondPoint.Y)
            {
                return true;
            }

            return false;
        }

        public int GetHashCode(Point obj)
        {
            return obj.GetHashCode();
        }
    }
}
